package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseBattleStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="水幕天河")
@Order(1)
@Component
public class ShuiMuTianHe extends BaseBattleStrategy {
    @Override
    public ElementEnum getElement() {
        return ElementEnum.WATER;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        BuffContent buffContent = new BuffContent();
        buffContent.setDuration(5);
        buffContent.setNum(1);
        first.getBuff().put("水幕", buffContent);
        first.getFlag().put("水幕天河","1");
        //扣蓝
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp()-500);
        content.getMsgLog().add(first.getUserBO().getName() + "使用了水幕天河，强行改变了场地环境");
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("水") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用水幕天河必须具有水灵根");
        }
    }

    @Override
    public String limitDesc() {
        return "具有水灵根";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        String flag = (String) user.getFlag().get("水幕天河");
        if (StringUtils.isNotBlank(flag)) {
            return false;
        }
        //校验蓝
        if (user.getBattleInfo().getCmp() < 500) {
            return false;
        }
        return true;
    }

    @Override
    public String desc() {
        return "尽可能优先释放（优先级同剑心诀），仅会释放一次，蓝耗500点，降低对方30%的速度，持续5回合，场地buff，无法被清心咒消除，当场地buff存在时，每回合会受到0.3的法术伤害";
    }
}
